home *** CD-ROM | disk | FTP | other *** search
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% December 1989
-
-
- XICON -- Execute Command File from an Icon
-
- Release 2.5
-
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- Copyright (c) 1986, 1987 , 1989 by Pete Goodeve -- All Rights Reserved
-
- Permission is granted to distribute this program freely, provided that
- no charge is made for its use. For any commercial purposes, please
- contact the author:
-
- Pete Goodeve
- 3012 Deakin Street #D
- Berkeley, Calif. 94705
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-
- With this program you can execute a file of AmigaDOS CLI commands
- directly from a WorkBench window, rather than from the CLI, simply by
- double-clicking an associated icon in the window. A window will be
- opened to display the output of the commands. It is similar to
- Commodore's IconX, but has been around about two years longer and
- has a number of facilities that the other lacks.
-
- This is release 2.5 of XICON. In addition to all the features of the
- previous version, it now changes to the current directory automatically
- before running the script, and can now invoke the "EXECUTE" DOS command to
- run it (giving you the use of IF, THEN, and ELSE) if necessary. You can
- pass other icons as parameters to EXECUTE scripts by multiple selection.
-
-
-
- Basic Concepts: The straightforward use of XICON is to have a 'project'
- =============== type icon, with XICON as the Default Tool, associated
- with a file of CLI commands (a "script"): when you
- double-click on the icon the commands in the file will be executed. A
- full-screen window is opened to display their output. The window will
- remain open when the script is finished until you either click on the Close
- gadget or type a control-C (or -D). The current directory when the script
- is entered is the same as that containing the icon.
-
- Many changes can be rung on this basic behavior by adding "Tool Types"
- to the icon's info. (These ToolTypes are all treated more extensively in
- their own sections later.) For example, the window can be configured to
- close automatically by setting the ToolType 'MODE=closewindow' in the icon.
- If none of the commands have any output that you need to see, set it to
- "'MODE=nowindow' and the program will not bother to open a window at all
- (any output is just thrown away).
-
- To set the size of the window that will be opened, use the Tool
- Type 'WINDOW=...'. To change its title at any point in the sequence,
- use 'TITLE=...'. (These options and all the others are described in
- detail in their own sections below.)
-
- You also have the option of executing commands from the ToolTypes lines
- of the icon itself, if you specify them with the 'CMD=...' ToolType.
- (There are advantages and disadvantages to this.) You can specify
- additional command scripts (which will be executed before the one
- associated with the icon) with 'SCRIPT=...'. This ToolType always
- executes the specified script directly (it doesn't invoke the DOS
- 'EXECUTE' command); if your script has conditional commands in it,
- you will need to use 'EXECUTE=...' instead. The script attached to
- the icon itself will be run via EXECUTE automatically if the first
- character is a period.
-
- You can include a remark to be displayed in the window with 'REM=...', or a
- text file with 'TEXT=...'. You can include as many instances of these
- particular Tool Types as you like (unlike configuration settings such as
- 'MODE' or 'WINDOW'); they are processed in sequence. The sequence may
- include a wait for a signal from the user with 'PAUSE'.
-
- For some applications it may be of more use to have some file other than a
- script attached to the icon -- under WorkBench 1.3, in fact, an icon
- doesn't need any associated file at all. If you set 'MODE=noscript' the
- attached file can be any type of data -- even a directory; you can operate
- on it if you want with commands in the ToolTypes list. If you set
- 'MODE=text' it will be treated as a simple text file to be displayed
- a page at a time in the window.
-
- You can take special action if the sequence has been aborted (except
- when you cut a test display short) -- see the description of the
- 'ABORT-...' Tool Types below. You can also use the 'EXISTS=...'
- ToolType to see if a file exists, and abort if it doesn't.
-
-
-
- Multiple Icons: You can select more than one icon at a time if you
- ============== like, by holding down the Shift key as you click on
- each. Only DOUBLE-click on the LAST selection (or use
- the "Open" item in the WorkBench Menu -- see "Introduction to Amiga").
-
- The behavior in shift-select mode has changed somewhat in this version: the
- icons are processed in sequence from first to last, and as long as none of
- the attached scripts begins with a period (i.e. requires 'EXECUTE') all the
- ToolTypes and scripts are processed in sequence as well (and as in earlier
- versions); however, if any attached script DOES begin with a period, ALL
- the remaining icons are just taken as parameters to the script, without any
- further processing -- i.e. the icon names (minus the '.info' suffix of
- course) are passed as command line parameters to the script. The
- 'EXECUTE=...' ToolType, on the other hand, does not work this way; it can
- never be passed parameters, though they can be included in the ToolType
- itself (see the section on this ToolType below).
-
-
-
- Text Display: When XICON is in the text display mode ('MODE=text' or
- ============ 'TEXT=...') the file is displayed a window-full at a
- time, assuming a full screen window. It will also
- pause if a form-feed character is encountered. To continue, type any key
- or click in the bottom border of the window. You can abort display of that
- file by either clicking in the Close gadget or typing control-C; it will
- immediately proceed to the next operation if any. You will have to repeat
- the action to exit XICON if there are no more operations. Note that this
- is different from the immediate exit that follows a click on the Close
- gadget in reponse to a PAUSE Tool Type.
-
-
-
- Setup: You can install Xicon itself in any convenient
- ===== directory: best is to use the 'C:' directory of your
- Workbench disk; or you could install it in a directory
- on the same disk as the icons. (It doesn't need an icon of its own. The
- one supplied is just for "introductory" purposes.) Whichever directory you
- use, the icons that are going to invoke it must have a matching pathname as
- their DEFAULT TOOL (see below).
-
- You can put an icon and its associated file in any directory ("drawer")
- that you can open under WorkBench. The file must of course have the same
- name as the icon (without the '.info' extension the icon has tacked on).
- Each icon must be of type 'PROJECT' with a DEFAULT TOOL string specifying
- a path to the Xicon program. If it is in the same directory, 'xicon' will
- suffice, otherwise you must use the complete pathname. A full pathname
- always begins with the "device name", which is either an actual device
- (e.g. DF0: or RAM:) or an assigned name (e.g. SYS: or C:). (See the DOS
- manual.) If the icons are on the same disk as Xicon, the device can be
- simply ":" (the colon character alone); for example, if the program
- 'xicon' is in the directory 'xicon' on the same disk as the icon,
- the default tool pathname would be:
-
- :XICON/XICON
-
- If it is in your system "C:" directory, set the entry to:
-
- C:XICON
-
-
-
- Command Scripts: There are many ways to generate Command Script
- =============== files with their icons. One simple approach is
- to duplicate an already existing Xicon icon/file
- pair and rename it (using WorkBench Menu operations), then go to the CLI
- and modify the text file using whatever editor you are comfortable with. If
- Xicon is not in the appropriate directory, you will also have to change the
- Default Tool in the icon to the correct pathname (see below for how to do
- this).
-
- Alternatively you can create the text file first (let's call it 'myscript'),
- then use the CLI to copy a suitable project icon to 'myscript.info' and
- modify it as necessary.
-
-
-
- Modifying an icon: All the changes you should need to make to an icon
- ================= (except change its appearance! -- there are a
- number of ways of doing that these days) can be
- done with the 'Info' item in the WorkBench Menu. Select the icon you want
- to modify by clicking on it, depress the right mouse button to bring up the
- menu, and select 'Info' from the 'WorkBench' section. This should bring up
- an information window for that icon.
-
- To set the DEFAULT TOOL, click in that gadget and type in (or edit) the
- string.
-
- To enter a new TOOL TYPE, click first on the ADD gadget, then click in the
- string gadget and type it in. If you want to insert it into an existing
- set, use the arrow gadgets on the left to move to the desired point first.
- You can of course edit the strings in the usual way. Use the DEL gadget
- to remove a line completely.
-
- When you are done, click in the SAVE box to preserve the changes.
- Note that there is a highly annoying bug in all the releases of WorkBench,
- until the very latest (1.3.2) where it has been finally fixed: very often
- the set of Tool Types you enter into the icon gets screwed up -- apparently
- the string terminator gets lost on some entries, causing the next string to
- be tagged on. The only fix seems to be to go back to the Info, re-edit all
- your clobbered Tool Types, and try saving again. Eventually this should
- work.
-
-
-
- Scripts with Conditional Commands and Parameters: It is possible to
- ================================================ invoke scripts that
- contain conditional
- DOS commands (IF, ELSE, etc). To do this, Xicon needs to have the EXECUTE
- command available in the C: directory (as well as the RUN command, which it
- has always needed). The FIRST character of a script that contains
- conditional commands (at least if it is the file directly attached to the
- icon), must be a period ".". This may be the first character of a
- ".KEY..." script directive (see EXECUTE in the DOS Manual) or sometimes you
- can simply use a period by itself on the line.
-
- If you intend to use EXECUTE, and don't actually have any .KEY parameters,
- it will probably still save you a lot of grief to simply use a dummy
- directive of the form:
- .K ""
-
- where the "" supplies a null parameter that EXECUTE will ignore. Otherwise
- a "<" character occurring ANYWHERE in your script (even in a comment!) will
- cause EXECUTE to complain "No .K directive". [Just one more of the Amazing
- features of DOS...]
-
- If the first character of an attached script is NOT a period, Xicon runs
- the sequence of commands directly, just as it always has.
-
-
-
- MODE Setting: You can alter the assumptions made by Xicon by
- ============ setting the Tool Type 'MODE'.
-
- 'MODE=closewindow' avoids having to use control-C or the Close
- gadget to terminate the program. The window will close as soon
- as all the commands have completed.
-
- 'MODE=nowindow' tells XICON not to open any window at all. Any
- output from executing commands is simply thrown away (sent to NIL:).
-
- 'MODE=noscript' prevents Xicon from trying to read commands from
- its associated file, so this can be of any type. This option only
- makes sense if some ToolType such as 'SCRIPT=...', 'TEXT=...' or
- 'CMD=...' is used to supply the commands.
-
- 'MODE=text' indicates that the associated file is text, and should
- be displayed a window-full at a time.
-
- Only one MODE entry will be recognized in the Tool Types array, so if you
- want more than one of the above options, you must specify them separated
- by the vertical-bar character, for example: 'MODE=noscript|closewindow'.
-
-
-
- Modifying the Window: You can specify the size, position and title of
- ==================== the window that XICON opens by setting the Tool
- Type 'WINDOW=xxx/yyy/www/hhh/Title', where xxx
- and yyy are the co-ordinates of the top left corner, www and hhh are width
- and height, and Title is the desired name for the window. In other words
- this is just the string you would use to specify a 'CON:' window from the
- CLI, WITHOUT the 'CON:' prefix itself.
-
- You can't change the size or position of the window once it has
- been opened, but you can change its title. Just include the Tool Type
- 'TITLE=title string'. You can use this more than once in a sequence
- (of Tool Type commands -- see below) if you want.
-
-
-
- Commands in the Icon: Instead of a script file, you can specify
- ==================== commands directly in the Tool Types array of
- the icon, with the 'CMD=command string' format.
- (For example: 'CMD=list df1:work'.)
-
- Include as many of these as you like. They will be executed in sequence,
- but each by a separate CLI process, so you can't use a command to set
- parameters like stack size or current directory for the ones that follow.
- A Command Script file on the other hand is executed completely by one
- process, so settings are inherited. Before each 'CMD=...' is executed, the
- current directory is set to that of the icon.
-
- If you want to execute additional command script files before the one
- associated with the icon (if any), use 'SCRIPT=filename'. As usual,
- 'filename' may either be the name of a script file in the same directory
- as the icon, or it may be the complete pathname of such a file. These
- lines may be interspersed with 'CMD=..' lines (or others) and will be
- taken in their turn. Again, each 'SCRIPT=..' is handled by a separate
- CLI process, and the current directory is set.
-
- You can also invoke the DOS EXECUTE on any script through a ToolType entry:
-
- EXECUTE=scriptname arg1 arg2....
-
- where 'scriptname' is the script file you wish to run , and 'arg1' etc
- are optional arguments (parameters) to pass to the script -- if it has a
- suitable '.KEY' directive to accept them (see your DOS manual under
- 'EXECUTE').
-
- Note that -- unlike the automatic decision as to whether to use EXECUTE on
- an attached script (according to whether or not it begins with a period) --
- 'EXECUTE=...' always uses EXECUTE, while 'SCRIPT=...' never does. (An
- initial period is not even required for the former, which may help some DOS
- shell scripts to run without modification.)
-
-
-
- Console Interaction: Any script run via EXECUTE is also run in
- =================== "interactive" mode. In other words a command
- in it that expects input from the console will
- wait for it properly. This was hard to arrange in earlier versions of
- Xicon: you had to resort to tricks like opening a special input window.
-
- Actually a new CLI is being created for this, and terminated when done. If
- the script fails, it can dump you into this CLI (and you will see a
- standard prompt). If this happens, simply type "endcli" to get out; you'll
- have to click on the close gadget as well, of course, if the icon doesn't
- have 'MODE=closewindow'.
-
- Unfortunately nothing ever seems to be entirely free. If any program
- invoked by the script accesses the console for input, this also diverts
- access away (permanently) from Xicon, meaning that you can no longer
- close the window with control-C. You still have the Close gadget, of
- course, or you can set MODE=closewindow to terminate automatically.
-
- In some cases also it seems possible that programs run in this mode may not
- pick up a control-C abort themselves , so you STILL may have to use special
- tricks. Sorry.
-
-
-
- Other Tool Types: You have various other actions that you can
- ================ request with Tool Type strings. They may be
- intermixed with the previous types.
-
- 'TEXT=filename' displays the specified file in the window, in
- the same way that 'MODE=text' does for the main file.
-
- 'REM=text' displays the text line as a remark at that point.
-
- 'PAUSE' (Note -- no "="!) pauses the sequence at that point,
- as if a form-feed had been encountered in a text file.
- Continue by clicking in the bottom border of the window or
- typing any key. If you click in the Close gadget instead,
- or type control-C, all remaining Tool Type commands will be
- skipped except 'RESTORE' and those with the 'ABORT-' prefix.
-
- 'RESTORE' is only relevant if the sequence has been aborted.
- If it is is encountered it removes the abort condition;
- Tool Type commands following it and the file associated
- with the icon will then be executed as normal.
-
- 'EXISTS=filename' will set the abort condition (as if the Close
- gadget had been clicked or control-C typed) if the specified
- file doesn't exist.
-
-
-
- The 'abort' condition: If the Close gadget is clicked or control-C
- ===================== typed in response to a PAUSE, or if an
- 'EXISTS=...' Tool Type fails, the abort
- condition will be set; all further normal Tool Type commands, and
- execution or display of the file associated with the icon, will be
- suppressed. If the 'RESTORE' Tool Type is encountered, however,
- normal operation will be restored.
-
- There are a set of alternative Tool Type commands, corresponding to
- the normal ones but prefixed with 'ABORT-', that will ONLY be executed
- if the abort condition has been set. The set is:
-
- ABORT-REM=...
- ABORT-CMD=...
- ABORT-TEXT=...
- ABORT-SCRIPT=...
- ABORT-EXECUTE...
- ABORT-PAUSE
-
- Note that the last one behaves JUST like normal PAUSE -- in other words
- if you click in the Continue gadget or type a key other than control-C
- the abort condition is REMOVED.
-
-
-
- Sequence of Tool Types: Remember the difference between the Tool Types
- ====================== that control the environment ('MODE=...',
- 'WINDOW=...', etc.) and those that are scanned
- in sequence. The first appearance of each of the former will be recognized
- at startup -- and at startup only -- so they won't for example be affected
- by an abort condition. They may actually be placed anywhere in the set of
- Tool Types, in any order, and they will still be recognized.
-
- The Tool Types processed at startup are:
-
- MODE=
- WINDOW=
- LOCDIR=
-
- Those processed in sequence are:
-
- CMD=
- REM=
- SCRIPT=
- EXECUTE=
- TEXT=
- TITLE=
- PAUSE
- RESTORE
- EXISTS=
- ABORT-...
-
- If you misspell a Tool Type name, it will simply be ignored.
-
-
-
- Finding the Directory: Previous to version 2.5, Xicon couldn't set the
- ===================== current directory automatically before running a
- script, so the ToolType 'LOCDIR=filename' was
- provided. This is now as far as I can tell totally redundant, but it has
- been left available so that earlier scripts will still work.
-
- If you include this ToolType in the icon, the specified file will be
- created and filled with a text string giving the complete path name of the
- directory containing the icon. Commands in the script can refer to this
- file -- which should be in a known place such as RAM: -- to take
- appropriate action. The string is always enclosed in quotes, and has a
- newline character at the end. DOS commands such as CD or DIR can read this
- string simply by redirecting their input and prompting with '?' (for
- commands like CD which don't have any needed output you can suppress the
- prompt by redirecting output to NIL:).
-
-
-
- Caveats:
- =======
-
- Remember that the DOS command file "RUN" must be available in the "C:"
- directory for Xicon to operate, and so must the "EXECUTE" command if
- you want to run that type of script file.
-
- Because Xicon's method of direct script execution sets up the command
- file as the input stream, the output window cannot be used as a console
- unless the file is run via EXECUTE. If a command in a direct script
- needs keyboard input it must open up its own console window using I/O
- redirection, e.g.:
-
- mycommand <CON:0/100/150/50/input
-
-
- The initial stack size is always 4000 bytes. You can change this in
- your command script with a suitable STACK command. Note that the STACK
- gadget in the icon Info window does not have any effect. (Except on
- the stack used by Xicon itself! I haven't investigated how much it
- needs.)
-
- Remember that DOS won't let you use IF, SKIP, QUIT, and so on in direct
- command script files. Use the EXECUTE mode for these.
-
- You can use the RUN command from a command script, of course, but there
- are problems with output in this situation. In some cases, RUNning
- multiple commands can result in a Guru -- apparently from output stream
- "collision". For safety, ALWAYS direct the output of RUN itself to
- 'NIL:', and the output of the commands RUN either to their own window
- or to 'NIL:' also. E.g.:
-
- RUN >NIL: mycommand > "CON:100/50/200/100/mycommand output"
-
-
- %%%%%%%%%%%%%%%%
-
-